package org.myminidao.dao;

import java.lang.reflect.Proxy;
import java.sql.Connection;

public class DaoCreate<T> {
	private Class<T> daoInterface;
	
	private DaoProxy<T> daoProxy;
	
	@SuppressWarnings("unchecked")
	public T createDao(Connection connection) {
		daoProxy = new DaoProxy<T>(connection, daoInterface);
		return (T)Proxy.newProxyInstance(daoInterface.getClassLoader(), new Class[] {daoInterface}, daoProxy);
	}

	public Class<T> getDaoInterface() {
		return daoInterface;
	}

	public void setDaoInterface(Class<T> type) {
		this.daoInterface = type;
	}
}
